import globals from 'globals'
import pluginJs from '@eslint/js'
import tseslint from 'typescript-eslint'
import eslintPluginVue from 'eslint-plugin-vue'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'

/** @type {import('eslint').Linter.Config[]} */
export default tseslint.config(
  {
    ignores: [
      'node_modules',
      '.idea',
      'dist',
      '.vscode',
      '.eslintcache',
      '.stylelintcache',
      '.eslintignore',
      '.prettierignore',
      '.stylelintignore',
      '.husky',
      'auto-imports.d.ts',
      'components.d.ts',
      'src/assets/iconfont/*',
      'package-lock.json',
      '*.timestamp-*.mjs'
    ]
  },
  {
    languageOptions: {
      globals: {
        ...globals.browser,
        ElMessage: 'readonly',
        ElMessageBox: 'readonly',
        ElLoading: 'readonly',
        RuleItem: 'readonly',
        RuleItemCb: 'readonly'
      }
    }
  },
  pluginJs.configs.recommended,
  ...tseslint.configs.recommended,
  ...eslintPluginVue.configs['flat/essential'],
  {
    files: ['**/*.vue'],
    languageOptions: {
      parserOptions: {
        parser: tseslint.parser,
        ecmaVersion: 'latest',
        ecmaFeatures: {
          jsx: true
        }
      }
    },
    rules: {
      'vue/no-mutating-props': [
        'error',
        {
          shallowOnly: true
        }
      ]
    }
  },
  {
    rules: {
      'vue/multi-word-component-names': 'off',
      eqeqeq: 2
    }
  },
  eslintPluginPrettierRecommended
)
